<?php 
class stock extends PHPUnit_Framework_TestCase
{
    private function gen_sign($params){
        // 私钥
        $token = '私钥';
        
        if(!$token){
            return false;
        }
        return strtoupper(md5(strtoupper(md5($this->assemble($params))).$token));
    }

    private function assemble($params)
    {
        if(!is_array($params))  return null;
        ksort($params, SORT_STRING);
        $sign = '';
        foreach($params AS $key=>$val){
            if(is_null($val))   continue;
            if(is_bool($val))   $val = ($val) ? 1 : 0;
            $sign .= $key . (is_array($val) ? $this->assemble($val) : $val);
        }
        return strtoupper(md5(strtoupper(md5($this->assemble($params))).$token));
    }

}